<?php
class mdl_auth extends CI_Model{ 
	
	var $tabel = 'macs_user';
	
	function __construct(){
		parent::__construct();
	} 
	
	function cekLogin($u,$p){ 
		 
		$c = array();
		$q = "
			SELECT 
				*
			FROM 
				".$this->tabel."
			WHERE user_name = '".$u."'
			AND user_password = '".$p."'
			AND user_status = '1'
			LIMIT 0,1
		";
		$query = $this->db->query($q);
		return array(
			'count'	=> $query->num_rows(),
			'data'	=> $query->row()
		);
		
	}
	
	function get_info_employee($uid=""){
		$r=array(
			"fullname" => "N/A",
			"foto"	   => "no-photo.jpg",
			"employee_id" => "0"
		); 
		if(trim($uid)!=""){
			$q = $this->db->query("
				select me.* from macs_user mu, macs_employee me
				where mu.user_employee_id = me.employee_id
				and mu.user_id = '".$uid."'
			")->row();
			if(count($q) > 0){
				$r=array(
					"fullname" 		=> $q->employee_fullname,
					"foto"	   		=> $q->employee_photo,
					"employee_id" 	=> $q->employee_id
				); 
			}
		}
		
		return $r;
	}
	
	
}